<?php

declare(strict_types=1);

namespace App\CustHub\Helpers;


use App\Common\Constants\JwtAuthSceneConstants;
use Mine\Helper\LoginUser;
use function Hyperf\Support\env;

class ChLoginUser extends LoginUser
{
    public function __construct(string $scene = JwtAuthSceneConstants::CUST_HUB_URL)
    {
        parent::__construct($scene);
    }

    public function getUsername(): string
    {
        return $this->jwt->getParserData()['nickname'] ?? '';
    }

    public function getMainUid()
    {
        $userInfo = $this->getUserInfo();
        $mainUid = $userInfo['parent_id'] == 0 ? $userInfo['id'] : $userInfo['parent_id'];
        return $mainUid;
    }

    /**
     * 是否超级管理员 默认是
     * @return bool
     */
    public function isSuperAdmin(): bool
    {
        $userInfo = $this->getUserInfo();
        if($userInfo['parent_id'] == 0){
            return true;
        }else{
            return false;
        }
    }

}